package com.ebpm.designer.menu
{
	import com.ebpm.designer.NodeContainer;
	import com.ebpm.designer.WF;
	
	import flash.events.MouseEvent;
	
	import mx.containers.Canvas;
	
	import spark.components.Group;
	import spark.primitives.BitmapImage;
	
	public class MenuItem extends Canvas
	{
		
		public var bi:BitmapImage = new BitmapImage();
		
		public var iconImage:Class;
		
		public var iconImageOver:Class;
		
		public function MenuItem(iconImage:Class, x:Number=0, y:Number=0)
		{
			this.x = x;
			this.y = y;
			this.width = WF.MENU_ITEM_WIDTH + 10;
			this.height = WF.MENU_ITEM_WIDTH + 10;
			
			var titleIcon:Canvas = new Canvas();
			titleIcon.x = 5;
			titleIcon.y = 5;
			titleIcon.width = WF.MENU_ITEM_WIDTH;
			titleIcon.height = WF.MENU_ITEM_HEIGHT;
			
			var group:Group = new Group();
			bi.source = getIconImage();
			bi.x = 0;
			bi.y = 0;
			bi.width = titleIcon.width;
			bi.height = titleIcon.height;
			group.addElement(bi);
			titleIcon.addElement(group);
			this.addElement(titleIcon);
			
			this.setStyle("backgroundColor", "#333333");
			this.setStyle("backgroundAlpha", 0.0);
			this.addEventListener(MouseEvent.MOUSE_OVER, _mouseOver);
			this.addEventListener(MouseEvent.MOUSE_OUT, _mouseOut);
			this.addEventListener(MouseEvent.CLICK, _click);
		}
		
		public function _mouseOver(event:MouseEvent):void {
			bi.source = this.getIconImageOver();
			this.setStyle("backgroundColor", "#003300");
			this.setStyle("backgroundAlpha", 0.2);
		}
		
		public function _mouseOut(event:MouseEvent):void {
			bi.source = this.getIconImage();
			this.setStyle("backgroundColor", "#333333");
			this.setStyle("backgroundAlpha", 0.0);
		}
		
		public function _click(event:MouseEvent):void
		{
//			WF.wp.removeAllItems();
			new NodeContainer(200, 100, WF.wp, "startEvent");
		}
		
		public function getIconImage(): Class {
			return null;
		}
		
		public function getIconImageOver(): Class {
			return null;
		}
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
	}
}